package adapter;

import java.util.Enumeration;
import java.util.Iterator;

/**
 * @author zhouyang
 * @title: EnumerationIterator
 * @projectName DesignMode_Java
 * @description: 迭代器到枚举器的适配
 * @date 2019/5/28 14:29
 */
public class EnumerationIterator implements Iterator<Object> {
    private Enumeration enumeration;

    public EnumerationIterator(Enumeration enumeration) {
        this.enumeration = enumeration;
    }

    @Override
    public boolean hasNext() {
        return this.enumeration.hasMoreElements();
    }

    @Override
    public Object next() {
        return this.enumeration.nextElement();
    }

    //不适配这个方法
    @Override
    public void remove() {
        throw new UnsupportedOperationException();
    }
}
